package longrise.phone.com.bjjt_henan.compensate;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.LFView;

import longrise.phone.com.bjjt_henan.R;

/**
 * 温馨提示，提示理赔金额，Created by Administrator on 2016/5/12.
 */

public class PromptAfterBankCardInfoView extends LFView implements View.OnClickListener {
    private Context context = null;
    private View view = null;
    private View btn_promptafterbankcardinfo;
    private TextView tv_title;
    private TextView tv_monney;
    private TextView tv_monney1;
    private String appcaseno;
    private EntityBean[] payBeans;
    private String casecarno;
    private LinearLayout hn_btn_back;
    private TextView tv_explain_he;
    private TextView tv_explain_me;
    private String ifSingle;
    private LinearLayout ll_payhe;
    private LinearLayout ll_payhe2;
    private LinearLayout ll_payme;

    public PromptAfterBankCardInfoView(Context c) {
        super(c);
        this.context = c;
    }

    public PromptAfterBankCardInfoView(Context c, String caseno, EntityBean[] beans) {
        super(c);
        this.context = c;
        this.appcaseno = caseno;
        this.payBeans = beans;
    }

    public void setUnqualifylist(String ifSingle) {
        this.ifSingle = ifSingle;
    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
    }

    private void initView() {
        view = View.inflate(context, R.layout.view_promptafterbankcardinfo, null);
        btn_promptafterbankcardinfo = (Button) view.findViewById(R.id.btn_promptafterbankcardinfo);
        tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_monney = (TextView) view.findViewById(R.id.tv_monney);
        tv_monney1 = (TextView) view.findViewById(R.id.tv_monney1);
        tv_explain_he = (TextView) view.findViewById(R.id.tv_explain_he);
        tv_explain_me = (TextView) view.findViewById(R.id.tv_explain_me);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_title.setText("温馨提示");
        EntityBean otherBean = null;//对方信息
        EntityBean myBean = null;//我的信息
        if (null != ifSingle && ifSingle.equals("0")) {
            ll_payhe = (LinearLayout) view.findViewById(R.id.ll_payhe);
            ll_payhe.setVisibility(View.GONE);
            ll_payhe2 = (LinearLayout) view.findViewById(R.id.ll_payhe2);
            ll_payhe2.setVisibility(View.GONE);
            ll_payme = (LinearLayout) view.findViewById(R.id.ll_payme);
            myBean = payBeans[0];
        } else {
            for (int i = 0; i < payBeans.length; i++) {
                String ownother = payBeans[i].getString("ownother");
                if (TextUtils.equals(ownother, "0")) {
                    myBean = payBeans[i];
                } else if (TextUtils.equals(ownother, "1")) {
                    otherBean = payBeans[i];
                }
            }
            String cpsmoney1 = otherBean.getString("cpsmoney");//对方赔付金额
            String feeinstructions1 = otherBean.getString("cpsresult");//对方赔付说明

            tv_monney1.setText(cpsmoney1);
            tv_explain_he.setText(feeinstructions1);
        }
        casecarno = myBean.getString("casecarno");
        String cpsmoney = myBean.getString("cpsmoney");//本方赔付金额
        String feeinstructions = myBean.getString("cpsresult");//本方赔付说明

        tv_monney.setText(cpsmoney);
        tv_explain_me.setText(feeinstructions);
    }

    private void regEvent(boolean b) {
        if (null != btn_promptafterbankcardinfo) {
            btn_promptafterbankcardinfo.setOnClickListener(b ? this : null);
        }

        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_promptafterbankcardinfo:
                //进入服务评价
                ServiceeValuateView serviceevaluateview = new ServiceeValuateView(context, appcaseno, casecarno);
                FrameworkManager.getInstance().showNewForm(context, serviceevaluateview);
                break;
            case R.id.hn_btn_back:
                closeForm();
                OnDestroy();
                break;
        }
    }

    @Override
    public void OnDestroy() {
        super.OnDestroy();
    }
}
